home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / gcc.info-12 (.txt) < prev    next >
GNU Info File  |  1993-10-21  |  45KB  |  790 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: Regs and Memory,  Next: Arithmetic,  Prev: Constants,  Up: RTL
  23. Registers and Memory
  24. ====================
  25.    Here are the RTL expression types for describing access to machine
  26. registers and to main memory.
  27. `(reg:M N)'
  28.      For small values of the integer N (those that are less than
  29.      `FIRST_PSEUDO_REGISTER'), this stands for a reference to machine
  30.      register number N: a "hard register".  For larger values of N, it
  31.      stands for a temporary value or "pseudo register".  The compiler's
  32.      strategy is to generate code assuming an unlimited number of such
  33.      pseudo registers, and later convert them into hard registers or
  34.      into memory references.
  35.      M is the machine mode of the reference.  It is necessary because
  36.      machines can generally refer to each register in more than one
  37.      mode.  For example, a register may contain a full word but there
  38.      may be instructions to refer to it as a half word or as a single
  39.      byte, as well as instructions to refer to it as a floating point
  40.      number of various precisions.
  41.      Even for a register that the machine can access in only one mode,
  42.      the mode must always be specified.
  43.      The symbol `FIRST_PSEUDO_REGISTER' is defined by the machine
  44.      description, since the number of hard registers on the machine is
  45.      an invariant characteristic of the machine.  Note, however, that
  46.      not all of the machine registers must be general registers.  All
  47.      the machine registers that can be used for storage of data are
  48.      given hard register numbers, even those that can be used only in
  49.      certain instructions or can hold only certain types of data.
  50.      A hard register may be accessed in various modes throughout one
  51.      function, but each pseudo register is given a natural mode and is
  52.      accessed only in that mode.  When it is necessary to describe an
  53.      access to a pseudo register using a nonnatural mode, a `subreg'
  54.      expression is used.
  55.      A `reg' expression with a machine mode that specifies more than
  56.      one word of data may actually stand for several consecutive
  57.      registers.  If in addition the register number specifies a
  58.      hardware register, then it actually represents several consecutive
  59.      hardware registers starting with the specified one.
  60.      Each pseudo register number used in a function's RTL code is
  61.      represented by a unique `reg' expression.
  62.      Some pseudo register numbers, those within the range of
  63.      `FIRST_VIRTUAL_REGISTER' to `LAST_VIRTUAL_REGISTER' only appear
  64.      during the RTL generation phase and are eliminated before the
  65.      optimization phases.  These represent locations in the stack frame
  66.      that cannot be determined until RTL generation for the function
  67.      has been completed.  The following virtual register numbers are
  68.      defined:
  69.     `VIRTUAL_INCOMING_ARGS_REGNUM'
  70.           This points to the first word of the incoming arguments
  71.           passed on the stack.  Normally these arguments are placed
  72.           there by the caller, but the callee may have pushed some
  73.           arguments that were previously passed in registers.
  74.           When RTL generation is complete, this virtual register is
  75.           replaced by the sum of the register given by
  76.           `ARG_POINTER_REGNUM' and the value of `FIRST_PARM_OFFSET'.
  77.     `VIRTUAL_STACK_VARS_REGNUM'
  78.           If `FRAME_GROWS_DOWNWARD' is defined, this points to
  79.           immediately above the first variable on the stack.
  80.           Otherwise, it points to the first variable on the stack.
  81.           `VIRTUAL_STACK_VARS_REGNUM' is replaced with the sum of the
  82.           register given by `FRAME_POINTER_REGNUM' and the value
  83.           `STARTING_FRAME_OFFSET'.
  84.     `VIRTUAL_STACK_DYNAMIC_REGNUM'
  85.           This points to the location of dynamically allocated memory
  86.           on the stack immediately after the stack pointer has been
  87.           adjusted by the amount of memory desired.
  88.           This virtual register is replaced by the sum of the register
  89.           given by `STACK_POINTER_REGNUM' and the value
  90.           `STACK_DYNAMIC_OFFSET'.
  91.     `VIRTUAL_OUTGOING_ARGS_REGNUM'
  92.           This points to the location in the stack at which outgoing
  93.           arguments should be written when the stack is pre-pushed
  94.           (arguments pushed using push insns should always use
  95.           `STACK_POINTER_REGNUM').
  96.           This virtual register is replaced by the sum of the register
  97.           given by `STACK_POINTER_REGNUM' and the value
  98.           `STACK_POINTER_OFFSET'.
  99. `(subreg:M REG WORDNUM)'
  100.      `subreg' expressions are used to refer to a register in a machine
  101.      mode other than its natural one, or to refer to one register of a
  102.      multi-word `reg' that actually refers to several registers.
  103.      Each pseudo-register has a natural mode.  If it is necessary to
  104.      operate on it in a different mode--for example, to perform a
  105.      fullword move instruction on a pseudo-register that contains a
  106.      single byte--the pseudo-register must be enclosed in a `subreg'.
  107.      In such a case, WORDNUM is zero.
  108.      Usually M is at least as narrow as the mode of REG, in which case
  109.      it is restricting consideration to only the bits of REG that are
  110.      in M.
  111.      Sometimes M is wider than the mode of REG.  These `subreg'
  112.      expressions are often called "paradoxical".  They are used in
  113.      cases where we want to refer to an object in a wider mode but do
  114.      not care what value the additional bits have.  The reload pass
  115.      ensures that paradoxical references are only made to hard
  116.      registers.
  117.      The other use of `subreg' is to extract the individual registers of
  118.      a multi-register value.  Machine modes such as `DImode' and
  119.      `TImode' can indicate values longer than a word, values which
  120.      usually require two or more consecutive registers.  To access one
  121.      of the registers, use a `subreg' with mode `SImode' and a WORDNUM
  122.      that says which register.
  123.      Storing in a non-paradoxical `subreg' has undefined results for
  124.      bits belonging to the same word as the `subreg'.  This laxity makes
  125.      it easier to generate efficient code for such instructions.  To
  126.      represent an instruction that preserves all the bits outside of
  127.      those in the `subreg', use `strict_low_part' around the `subreg'.
  128.      The compilation parameter `WORDS_BIG_ENDIAN', if set to 1, says
  129.      that word number zero is the most significant part; otherwise, it
  130.      is the least significant part.
  131.      Between the combiner pass and the reload pass, it is possible to
  132.      have a paradoxical `subreg' which contains a `mem' instead of a
  133.      `reg' as its first operand.  After the reload pass, it is also
  134.      possible to have a non-paradoxical `subreg' which contains a
  135.      `mem'; this usually occurs when the `mem' is a stack slot which
  136.      replaced a pseudo register.
  137.      Note that it is not valid to access a `DFmode' value in `SFmode'
  138.      using a `subreg'.  On some machines the most significant part of a
  139.      `DFmode' value does not have the same format as a single-precision
  140.      floating value.
  141.      It is also not valid to access a single word of a multi-word value
  142.      in a hard register when less registers can hold the value than
  143.      would be expected from its size.  For example, some 32-bit
  144.      machines have floating-point registers that can hold an entire
  145.      `DFmode' value.  If register 10 were such a register `(subreg:SI
  146.      (reg:DF 10) 1)' would be invalid because there is no way to
  147.      convert that reference to a single machine register.  The reload
  148.      pass prevents `subreg' expressions such as these from being formed.
  149.      The first operand of a `subreg' expression is customarily accessed
  150.      with the `SUBREG_REG' macro and the second operand is customarily
  151.      accessed with the `SUBREG_WORD' macro.
  152. `(scratch:M)'
  153.      This represents a scratch register that will be required for the
  154.      execution of a single instruction and not used subsequently.  It is
  155.      converted into a `reg' by either the local register allocator or
  156.      the reload pass.
  157.      `scratch' is usually present inside a `clobber' operation (*note
  158.      Side Effects::.).
  159. `(cc0)'
  160.      This refers to the machine's condition code register.  It has no
  161.      operands and may not have a machine mode.  There are two ways to
  162.      use it:
  163.         * To stand for a complete set of condition code flags.  This is
  164.           best on most machines, where each comparison sets the entire
  165.           series of flags.
  166.           With this technique, `(cc0)' may be validly used in only two
  167.           contexts: as the destination of an assignment (in test and
  168.           compare instructions) and in comparison operators comparing
  169.           against zero (`const_int' with value zero; that is to say,
  170.           `const0_rtx').
  171.         * To stand for a single flag that is the result of a single
  172.           condition.  This is useful on machines that have only a
  173.           single flag bit, and in which comparison instructions must
  174.           specify the condition to test.
  175.           With this technique, `(cc0)' may be validly used in only two
  176.           contexts: as the destination of an assignment (in test and
  177.           compare instructions) where the source is a comparison
  178.           operator, and as the first operand of `if_then_else' (in a
  179.           conditional branch).
  180.      There is only one expression object of code `cc0'; it is the value
  181.      of the variable `cc0_rtx'.  Any attempt to create an expression of
  182.      code `cc0' will return `cc0_rtx'.
  183.      Instructions can set the condition code implicitly.  On many
  184.      machines, nearly all instructions set the condition code based on
  185.      the value that they compute or store.  It is not necessary to
  186.      record these actions explicitly in the RTL because the machine
  187.      description includes a prescription for recognizing the
  188.      instructions that do so (by means of the macro
  189.      `NOTICE_UPDATE_CC').  *Note Condition Code::.  Only instructions
  190.      whose sole purpose is to set the condition code, and instructions
  191.      that use the condition code, need mention `(cc0)'.
  192.      On some machines, the condition code register is given a register
  193.      number and a `reg' is used instead of `(cc0)'.  This is usually the
  194.      preferable approach if only a small subset of instructions modify
  195.      the condition code.  Other machines store condition codes in
  196.      general registers; in such cases a pseudo register should be used.
  197.      Some machines, such as the Sparc and RS/6000, have two sets of
  198.      arithmetic instructions, one that sets and one that does not set
  199.      the condition code.  This is best handled by normally generating
  200.      the instruction that does not set the condition code, and making a
  201.      pattern that both performs the arithmetic and sets the condition
  202.      code register (which would not be `(cc0)' in this case).  For
  203.      examples, search for `addcc' and `andcc' in `sparc.md'.
  204. `(pc)'
  205.      This represents the machine's program counter.  It has no operands
  206.      and may not have a machine mode.  `(pc)' may be validly used only
  207.      in certain specific contexts in jump instructions.
  208.      There is only one expression object of code `pc'; it is the value
  209.      of the variable `pc_rtx'.  Any attempt to create an expression of
  210.      code `pc' will return `pc_rtx'.
  211.      All instructions that do not jump alter the program counter
  212.      implicitly by incrementing it, but there is no need to mention
  213.      this in the RTL.
  214. `(mem:M ADDR)'
  215.      This RTX represents a reference to main memory at an address
  216.      represented by the expression ADDR.  M specifies how large a unit
  217.      of memory is accessed.
  218. File: gcc.info,  Node: Arithmetic,  Next: Comparisons,  Prev: Regs and Memory,  Up: RTL
  219. RTL Expressions for Arithmetic
  220. ==============================
  221.    Unless otherwise specified, all the operands of arithmetic
  222. expressions must be valid for mode M.  An operand is valid for mode M
  223. if it has mode M, or if it is a `const_int' or `const_double' and M is
  224. a mode of class `MODE_INT'.
  225.    For commutative binary operations, constants should be placed in the
  226. second operand.
  227. `(plus:M X Y)'
  228.      Represents the sum of the values represented by X and Y carried
  229.      out in machine mode M.
  230. `(lo_sum:M X Y)'
  231.      Like `plus', except that it represents that sum of X and the
  232.      low-order bits of Y.  The number of low order bits is
  233.      machine-dependent but is normally the number of bits in a `Pmode'
  234.      item minus the number of bits set by the `high' code (*note
  235.      Constants::.).
  236.      M should be `Pmode'.
  237. `(minus:M X Y)'
  238.      Like `plus' but represents subtraction.
  239. `(compare:M X Y)'
  240.      Represents the result of subtracting Y from X for purposes of
  241.      comparison.  The result is computed without overflow, as if with
  242.      infinite precision.
  243.      Of course, machines can't really subtract with infinite precision.
  244.      However, they can pretend to do so when only the sign of the
  245.      result will be used, which is the case when the result is stored
  246.      in the condition code.   And that is the only way this kind of
  247.      expression may validly be used: as a value to be stored in the
  248.      condition codes.
  249.      The mode M is not related to the modes of X and Y, but instead is
  250.      the mode of the condition code value.  If `(cc0)' is used, it is
  251.      `VOIDmode'.  Otherwise it is some mode in class `MODE_CC', often
  252.      `CCmode'.  *Note Condition Code::.
  253.      Normally, X and Y must have the same mode.  Otherwise, `compare'
  254.      is valid only if the mode of X is in class `MODE_INT' and Y is a
  255.      `const_int' or `const_double' with mode `VOIDmode'.  The mode of X
  256.      determines what mode the comparison is to be done in; thus it must
  257.      not be `VOIDmode'.
  258.      If one of the operands is a constant, it should be placed in the
  259.      second operand and the comparison code adjusted as appropriate.
  260.      A `compare' specifying two `VOIDmode' constants is not valid since
  261.      there is no way to know in what mode the comparison is to be
  262.      performed; the comparison must either be folded during the
  263.      compilation or the first operand must be loaded into a register
  264.      while its mode is still known.
  265. `(neg:M X)'
  266.      Represents the negation (subtraction from zero) of the value
  267.      represented by X, carried out in mode M.
  268. `(mult:M X Y)'
  269.      Represents the signed product of the values represented by X and Y
  270.      carried out in machine mode M.
  271.      Some machines support a multiplication that generates a product
  272.      wider than the operands.  Write the pattern for this as
  273.           (mult:M (sign_extend:M X) (sign_extend:M Y))
  274.      where M is wider than the modes of X and Y, which need not be the
  275.      same.
  276.      Write patterns for unsigned widening multiplication similarly using
  277.      `zero_extend'.
  278. `(div:M X Y)'
  279.      Represents the quotient in signed division of X by Y, carried out
  280.      in machine mode M.  If M is a floating point mode, it represents
  281.      the exact quotient; otherwise, the integerized quotient.
  282.      Some machines have division instructions in which the operands and
  283.      quotient widths are not all the same; you should represent such
  284.      instructions using `truncate' and `sign_extend' as in,
  285.           (truncate:M1 (div:M2 X (sign_extend:M2 Y)))
  286. `(udiv:M X Y)'
  287.      Like `div' but represents unsigned division.
  288. `(mod:M X Y)'
  289. `(umod:M X Y)'
  290.      Like `div' and `udiv' but represent the remainder instead of the
  291.      quotient.
  292. `(smin:M X Y)'
  293. `(smax:M X Y)'
  294.      Represents the smaller (for `smin') or larger (for `smax') of X
  295.      and Y, interpreted as signed integers in mode M.
  296. `(umin:M X Y)'
  297. `(umax:M X Y)'
  298.      Like `smin' and `smax', but the values are interpreted as unsigned
  299.      integers.
  300. `(not:M X)'
  301.      Represents the bitwise complement of the value represented by X,
  302.      carried out in mode M, which must be a fixed-point machine mode.
  303. `(and:M X Y)'
  304.      Represents the bitwise logical-and of the values represented by X
  305.      and Y, carried out in machine mode M, which must be a fixed-point
  306.      machine mode.
  307. `(ior:M X Y)'
  308.      Represents the bitwise inclusive-or of the values represented by X
  309.      and Y, carried out in machine mode M, which must be a fixed-point
  310.      mode.
  311. `(xor:M X Y)'
  312.      Represents the bitwise exclusive-or of the values represented by X
  313.      and Y, carried out in machine mode M, which must be a fixed-point
  314.      mode.
  315. `(ashift:M X C)'
  316.      Represents the result of arithmetically shifting X left by C
  317.      places.  X have mode M, a fixed-point machine mode.  C be a
  318.      fixed-point mode or be a constant with mode `VOIDmode'; which mode
  319.      is determined by the mode called for in the machine description
  320.      entry for the left-shift instruction.  For example, on the Vax,
  321.      the mode of C is `QImode' regardless of M.
  322. `(lshift:M X C)'
  323.      Like `ashift' but for logical left shift.  `ashift' and `lshift'
  324.      are identical operations; we customarily use `ashift' for both.
  325. `(lshiftrt:M X C)'
  326. `(ashiftrt:M X C)'
  327.      Like `lshift' and `ashift' but for right shift.  Unlike the case
  328.      for left shift, these two operations are distinct.
  329. `(rotate:M X C)'
  330. `(rotatert:M X C)'
  331.      Similar but represent left and right rotate.  If C is a constant,
  332.      use `rotate'.
  333. `(abs:M X)'
  334.      Represents the absolute value of X, computed in mode M.
  335. `(sqrt:M X)'
  336.      Represents the square root of X, computed in mode M.  Most often M
  337.      will be a floating point mode.
  338. `(ffs:M X)'
  339.      Represents one plus the index of the least significant 1-bit in X,
  340.      represented as an integer of mode M.  (The value is zero if X is
  341.      zero.)  The mode of X need not be M; depending on the target
  342.      machine, various mode combinations may be valid.
  343. File: gcc.info,  Node: Comparisons,  Next: Bit Fields,  Prev: Arithmetic,  Up: RTL
  344. Comparison Operations
  345. =====================
  346.    Comparison operators test a relation on two operands and are
  347. considered to represent a machine-dependent nonzero value described by,
  348. but not necessarily equal to, `STORE_FLAG_VALUE' (*note Misc::.) if the
  349. relation holds, or zero if it does not.  The mode of the comparison
  350. operation is independent of the mode of the data being compared.  If
  351. the comparison operation is being tested (e.g., the first operand of an
  352. `if_then_else'), the mode must be `VOIDmode'.  If the comparison
  353. operation is producing data to be stored in some variable, the mode
  354. must be in class `MODE_INT'.  All comparison operations producing data
  355. must use the same mode, which is machine-specific.
  356.    There are two ways that comparison operations may be used.  The
  357. comparison operators may be used to compare the condition codes `(cc0)'
  358. against zero, as in `(eq (cc0) (const_int 0))'.  Such a construct
  359. actually refers to the result of the preceding instruction in which the
  360. condition codes were set.  The instructing setting the condition code
  361. must be adjacent to the instruction using the condition code; only
  362. `note' insns may separate them.
  363.    Alternatively, a comparison operation may directly compare two data
  364. objects.  The mode of the comparison is determined by the operands; they
  365. must both be valid for a common machine mode.  A comparison with both
  366. operands constant would be invalid as the machine mode could not be
  367. deduced from it, but such a comparison should never exist in RTL due to
  368. constant folding.
  369.    In the example above, if `(cc0)' were last set to `(compare X Y)',
  370. the comparison operation is identical to `(eq X Y)'.  Usually only one
  371. style of comparisons is supported on a particular machine, but the
  372. combine pass will try to merge the operations to produce the `eq' shown
  373. in case it exists in the context of the particular insn involved.
  374.    Inequality comparisons come in two flavors, signed and unsigned.
  375. Thus, there are distinct expression codes `gt' and `gtu' for signed and
  376. unsigned greater-than.  These can produce different results for the same
  377. pair of integer values: for example, 1 is signed greater-than -1 but not
  378. unsigned greater-than, because -1 when regarded as unsigned is actually
  379. `0xffffffff' which is greater than 1.
  380.    The signed comparisons are also used for floating point values.
  381. Floating point comparisons are distinguished by the machine modes of
  382. the operands.
  383. `(eq:M X Y)'
  384.      1 if the values represented by X and Y are equal, otherwise 0.
  385. `(ne:M X Y)'
  386.      1 if the values represented by X and Y are not equal, otherwise 0.
  387. `(gt:M X Y)'
  388.      1 if the X is greater than Y.  If they are fixed-point, the
  389.      comparison is done in a signed sense.
  390. `(gtu:M X Y)'
  391.      Like `gt' but does unsigned comparison, on fixed-point numbers
  392.      only.
  393. `(lt:M X Y)'
  394. `(ltu:M X Y)'
  395.      Like `gt' and `gtu' but test for "less than".
  396. `(ge:M X Y)'
  397. `(geu:M X Y)'
  398.      Like `gt' and `gtu' but test for "greater than or equal".
  399. `(le:M X Y)'
  400. `(leu:M X Y)'
  401.      Like `gt' and `gtu' but test for "less than or equal".
  402. `(if_then_else COND THEN ELSE)'
  403.      This is not a comparison operation but is listed here because it is
  404.      always used in conjunction with a comparison operation.  To be
  405.      precise, COND is a comparison expression.  This expression
  406.      represents a choice, according to COND, between the value
  407.      represented by THEN and the one represented by ELSE.
  408.      On most machines, `if_then_else' expressions are valid only to
  409.      express conditional jumps.
  410. `(cond [TEST1 VALUE1 TEST2 VALUE2 ...] DEFAULT)'
  411.      Similar to `if_then_else', but more general.  Each of TEST1,
  412.      TEST2, ... is performed in turn.  The result of this expression is
  413.      the VALUE corresponding to the first non-zero test, or DEFAULT if
  414.      none of the tests are non-zero expressions.
  415.      This is currently not valid for instruction patterns and is
  416.      supported only for insn attributes.  *Note Insn Attributes::.
  417. File: gcc.info,  Node: Bit Fields,  Next: Conversions,  Prev: Comparisons,  Up: RTL
  418. Bit Fields
  419. ==========
  420.    Special expression codes exist to represent bitfield instructions.
  421. These types of expressions are lvalues in RTL; they may appear on the
  422. left side of an assignment, indicating insertion of a value into the
  423. specified bit field.
  424. `(sign_extract:M LOC SIZE POS)'
  425.      This represents a reference to a sign-extended bit field contained
  426.      or starting in LOC (a memory or register reference).  The bit field
  427.      is SIZE bits wide and starts at bit POS.  The compilation option
  428.      `BITS_BIG_ENDIAN' says which end of the memory unit POS counts
  429.      from.
  430.      If LOC is in memory, its mode must be a single-byte integer mode.
  431.      If LOC is in a register, the mode to use is specified by the
  432.      operand of the `insv' or `extv' pattern (*note Standard Names::.)
  433.      and is usually a full-word integer mode.
  434.      The mode of POS is machine-specific and is also specified in the
  435.      `insv' or `extv' pattern.
  436.      The mode M is the same as the mode that would be used for LOC if
  437.      it were a register.
  438. `(zero_extract:M LOC SIZE POS)'
  439.      Like `sign_extract' but refers to an unsigned or zero-extended bit
  440.      field.  The same sequence of bits are extracted, but they are
  441.      filled to an entire word with zeros instead of by sign-extension.
  442. File: gcc.info,  Node: Conversions,  Next: RTL Declarations,  Prev: Bit Fields,  Up: RTL
  443. Conversions
  444. ===========
  445.    All conversions between machine modes must be represented by
  446. explicit conversion operations.  For example, an expression which is
  447. the sum of a byte and a full word cannot be written as `(plus:SI
  448. (reg:QI 34) (reg:SI 80))' because the `plus' operation requires two
  449. operands of the same machine mode.  Therefore, the byte-sized operand
  450. is enclosed in a conversion operation, as in
  451.      (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  452.    The conversion operation is not a mere placeholder, because there
  453. may be more than one way of converting from a given starting mode to
  454. the desired final mode.  The conversion operation code says how to do
  455.    For all conversion operations, X must not be `VOIDmode' because the
  456. mode in which to do the conversion would not be known.  The conversion
  457. must either be done at compile-time or X must be placed into a register.
  458. `(sign_extend:M X)'
  459.      Represents the result of sign-extending the value X to machine
  460.      mode M.  M must be a fixed-point mode and X a fixed-point value of
  461.      a mode narrower than M.
  462. `(zero_extend:M X)'
  463.      Represents the result of zero-extending the value X to machine
  464.      mode M.  M must be a fixed-point mode and X a fixed-point value of
  465.      a mode narrower than M.
  466. `(float_extend:M X)'
  467.      Represents the result of extending the value X to machine mode M.
  468.      m must be a floating point mode and X a floating point value of a
  469.      mode narrower than M.
  470. `(truncate:M X)'
  471.      Represents the result of truncating the value X to machine mode M.
  472.      M must be a fixed-point mode and X a fixed-point value of a mode
  473.      wider than M.
  474. `(float_truncate:M X)'
  475.      Represents the result of truncating the value X to machine mode M.
  476.      M must be a floating point mode and X a floating point value of a
  477.      mode wider than M.
  478. `(float:M X)'
  479.      Represents the result of converting fixed point value X, regarded
  480.      as signed, to floating point mode M.
  481. `(unsigned_float:M X)'
  482.      Represents the result of converting fixed point value X, regarded
  483.      as unsigned, to floating point mode M.
  484. `(fix:M X)'
  485.      When M is a fixed point mode, represents the result of converting
  486.      floating point value X to mode M, regarded as signed.  How
  487.      rounding is done is not specified, so this operation may be used
  488.      validly in compiling C code only for integer-valued operands.
  489. `(unsigned_fix:M X)'
  490.      Represents the result of converting floating point value X to
  491.      fixed point mode M, regarded as unsigned.  How rounding is done is
  492.      not specified.
  493. `(fix:M X)'
  494.      When M is a floating point mode, represents the result of
  495.      converting floating point value X (valid for mode M) to an
  496.      integer, still represented in floating point mode M, by rounding
  497.      towards zero.
  498. File: gcc.info,  Node: RTL Declarations,  Next: Side Effects,  Prev: Conversions,  Up: RTL
  499. Declarations
  500. ============
  501.    Declaration expression codes do not represent arithmetic operations
  502. but rather state assertions about their operands.
  503. `(strict_low_part (subreg:M (reg:N R) 0))'
  504.      This expression code is used in only one context: as the
  505.      destination operand of a `set' expression.  In addition, the
  506.      operand of this expression must be a non-paradoxical `subreg'
  507.      expression.
  508.      The presence of `strict_low_part' says that the part of the
  509.      register which is meaningful in mode N, but is not part of mode M,
  510.      is not to be altered.  Normally, an assignment to such a subreg is
  511.      allowed to have undefined effects on the rest of the register when
  512.      M is less than a word.
  513. File: gcc.info,  Node: Side Effects,  Next: Incdec,  Prev: RTL Declarations,  Up: RTL
  514. Side Effect Expressions
  515. =======================
  516.    The expression codes described so far represent values, not actions.
  517. But machine instructions never produce values; they are meaningful only
  518. for their side effects on the state of the machine.  Special expression
  519. codes are used to represent side effects.
  520.    The body of an instruction is always one of these side effect codes;
  521. the codes described above, which represent values, appear only as the
  522. operands of these.
  523. `(set LVAL X)'
  524.      Represents the action of storing the value of X into the place
  525.      represented by LVAL.  LVAL must be an expression representing a
  526.      place that can be stored in: `reg' (or `subreg' or
  527.      `strict_low_part'), `mem', `pc' or `cc0'.
  528.      If LVAL is a `reg', `subreg' or `mem', it has a machine mode; then
  529.      X must be valid for that mode.
  530.      If LVAL is a `reg' whose machine mode is less than the full width
  531.      of the register, then it means that the part of the register
  532.      specified by the machine mode is given the specified value and the
  533.      rest of the register receives an undefined value.  Likewise, if
  534.      LVAL is a `subreg' whose machine mode is narrower than the mode of
  535.      the register, the rest of the register can be changed in an
  536.      undefined way.
  537.      If LVAL is a `strict_low_part' of a `subreg', then the part of the
  538.      register specified by the machine mode of the `subreg' is given
  539.      the value X and the rest of the register is not changed.
  540.      If LVAL is `(cc0)', it has no machine mode, and X may be either a
  541.      `compare' expression or a value that may have any mode.  The
  542.      latter case represents a "test" instruction.  The expression `(set
  543.      (cc0) (reg:M N))' is equivalent to `(set (cc0) (compare (reg:M N)
  544.      (const_int 0)))'.  Use the former expression to save space during
  545.      the compilation.
  546.      If LVAL is `(pc)', we have a jump instruction, and the
  547.      possibilities for X are very limited.  It may be a `label_ref'
  548.      expression (unconditional jump).  It may be an `if_then_else'
  549.      (conditional jump), in which case either the second or the third
  550.      operand must be `(pc)' (for the case which does not jump) and the
  551.      other of the two must be a `label_ref' (for the case which does
  552.      jump).  X may also be a `mem' or `(plus:SI (pc) Y)', where Y may
  553.      be a `reg' or a `mem'; these unusual patterns are used to
  554.      represent jumps through branch tables.
  555.      If LVAL is neither `(cc0)' nor `(pc)', the mode of LVAL must not
  556.      be `VOIDmode' and the mode of X must be valid for the mode of LVAL.
  557.      LVAL is customarily accessed with the `SET_DEST' macro and X with
  558.      the `SET_SRC' macro.
  559. `(return)'
  560.      As the sole expression in a pattern, represents a return from the
  561.      current function, on machines where this can be done with one
  562.      instruction, such as Vaxes.  On machines where a multi-instruction
  563.      "epilogue" must be executed in order to return from the function,
  564.      returning is done by jumping to a label which precedes the
  565.      epilogue, and the `return' expression code is never used.
  566.      Inside an `if_then_else' expression, represents the value to be
  567.      placed in `pc' to return to the caller.
  568.      Note that an insn pattern of `(return)' is logically equivalent to
  569.      `(set (pc) (return))', but the latter form is never used.
  570. `(call FUNCTION NARGS)'
  571.      Represents a function call.  FUNCTION is a `mem' expression whose
  572.      address is the address of the function to be called.  NARGS is an
  573.      expression which can be used for two purposes: on some machines it
  574.      represents the number of bytes of stack argument; on others, it
  575.      represents the number of argument registers.
  576.      Each machine has a standard machine mode which FUNCTION must have.
  577.      The machine description defines macro `FUNCTION_MODE' to expand
  578.      into the requisite mode name.  The purpose of this mode is to
  579.      specify what kind of addressing is allowed, on machines where the
  580.      allowed kinds of addressing depend on the machine mode being
  581.      addressed.
  582. `(clobber X)'
  583.      Represents the storing or possible storing of an unpredictable,
  584.      undescribed value into X, which must be a `reg', `scratch' or
  585.      `mem' expression.
  586.      One place this is used is in string instructions that store
  587.      standard values into particular hard registers.  It may not be
  588.      worth the trouble to describe the values that are stored, but it
  589.      is essential to inform the compiler that the registers will be
  590.      altered, lest it attempt to keep data in them across the string
  591.      instruction.
  592.      If X is `(mem:BLK (const_int 0))', it means that all memory
  593.      locations must be presumed clobbered.
  594.      Note that the machine description classifies certain hard
  595.      registers as "call-clobbered".  All function call instructions are
  596.      assumed by default to clobber these registers, so there is no need
  597.      to use `clobber' expressions to indicate this fact.  Also, each
  598.      function call is assumed to have the potential to alter any memory
  599.      location, unless the function is declared `const'.
  600.      If the last group of expressions in a `parallel' are each a
  601.      `clobber' expression whose arguments are `reg' or `match_scratch'
  602.      (*note RTL Template::.) expressions, the combiner phase can add
  603.      the appropriate `clobber' expressions to an insn it has
  604.      constructed when doing so will cause a pattern to be matched.
  605.      This feature can be used, for example, on a machine that whose
  606.      multiply and add instructions don't use an MQ register but which
  607.      has an add-accumulate instruction that does clobber the MQ
  608.      register.  Similarly, a combined instruction might require a
  609.      temporary register while the constituent instructions might not.
  610.      When a `clobber' expression for a register appears inside a
  611.      `parallel' with other side effects, the register allocator
  612.      guarantees that the register is unoccupied both before and after
  613.      that insn.  However, the reload phase may allocate a register used
  614.      for one of the inputs unless the `&' constraint is specified for
  615.      the selected alternative (*note Modifiers::.).  You can clobber
  616.      either a specific hard register, a pseudo register, or a `scratch'
  617.      expression; in the latter two cases, GNU CC will allocate a hard
  618.      register that is available there for use as a temporary.
  619.      For instructions that require a temporary register, you should use
  620.      `scratch' instead of a pseudo-register because this will allow the
  621.      combiner phase to add the `clobber' when required.  You do this by
  622.      coding (`clobber' (`match_scratch' ...)).  If you do clobber a
  623.      pseudo register, use one which appears nowhere else--generate a
  624.      new one each time.  Otherwise, you may confuse CSE.
  625.      There is one other known use for clobbering a pseudo register in a
  626.      `parallel': when one of the input operands of the insn is also
  627.      clobbered by the insn.  In this case, using the same pseudo
  628.      register in the clobber and elsewhere in the insn produces the
  629.      expected results.
  630. `(use X)'
  631.      Represents the use of the value of X.  It indicates that the value
  632.      in X at this point in the program is needed, even though it may
  633.      not be apparent why this is so.  Therefore, the compiler will not
  634.      attempt to delete previous instructions whose only effect is to
  635.      store a value in X.  X must be a `reg' expression.
  636.      During the delayed branch scheduling phase, X may be an insn.
  637.      This indicates that X previously was located at this place in the
  638.      code and its data dependencies need to be taken into account.
  639.      These `use' insns will be deleted before the delayed branch
  640.      scheduling phase exits.
  641. `(parallel [X0 X1 ...])'
  642.      Represents several side effects performed in parallel.  The square
  643.      brackets stand for a vector; the operand of `parallel' is a vector
  644.      of expressions.  X0, X1 and so on are individual side effect
  645.      expressions--expressions of code `set', `call', `return',
  646.      `clobber' or `use'.
  647.      "In parallel" means that first all the values used in the
  648.      individual side-effects are computed, and second all the actual
  649.      side-effects are performed.  For example,
  650.           (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
  651.                      (set (mem:SI (reg:SI 1)) (reg:SI 1))])
  652.      says unambiguously that the values of hard register 1 and the
  653.      memory location addressed by it are interchanged.  In both places
  654.      where `(reg:SI 1)' appears as a memory address it refers to the
  655.      value in register 1 *before* the execution of the insn.
  656.      It follows that it is *incorrect* to use `parallel' and expect the
  657.      result of one `set' to be available for the next one.  For
  658.      example, people sometimes attempt to represent a jump-if-zero
  659.      instruction this way:
  660.           (parallel [(set (cc0) (reg:SI 34))
  661.                      (set (pc) (if_then_else
  662.                                   (eq (cc0) (const_int 0))
  663.                                   (label_ref ...)
  664.                                   (pc)))])
  665.      But this is incorrect, because it says that the jump condition
  666.      depends on the condition code value *before* this instruction, not
  667.      on the new value that is set by this instruction.
  668.      Peephole optimization, which takes place together with final
  669.      assembly code output, can produce insns whose patterns consist of
  670.      a `parallel' whose elements are the operands needed to output the
  671.      resulting assembler code--often `reg', `mem' or constant
  672.      expressions.  This would not be well-formed RTL at any other stage
  673.      in compilation, but it is ok then because no further optimization
  674.      remains to be done.  However, the definition of the macro
  675.      `NOTICE_UPDATE_CC', if any, must deal with such insns if you
  676.      define any peephole optimizations.
  677. `(sequence [INSNS ...])'
  678.      Represents a sequence of insns.  Each of the INSNS that appears in
  679.      the vector is suitable for appearing in the chain of insns, so it
  680.      must be an `insn', `jump_insn', `call_insn', `code_label',
  681.      `barrier' or `note'.
  682.      A `sequence' RTX is never placed in an actual insn during RTL
  683.      generation.  It represents the sequence of insns that result from a
  684.      `define_expand' *before* those insns are passed to `emit_insn' to
  685.      insert them in the chain of insns.  When actually inserted, the
  686.      individual sub-insns are separated out and the `sequence' is
  687.      forgotten.
  688.      After delay-slot scheduling is completed, an insn and all the
  689.      insns that reside in its delay slots are grouped together into a
  690.      `sequence'.  The insn requiring the delay slot is the first insn
  691.      in the vector; subsequent insns are to be placed in the delay slot.
  692.      `INSN_ANNULLED_BRANCH_P' is set on an insn in a delay slot to
  693.      indicate that a branch insn should be used that will conditionally
  694.      annul the effect of the insns in the delay slots.  In such a case,
  695.      `INSN_FROM_TARGET_P' indicates that the insn is from the target of
  696.      the branch and should be executed only if the branch is taken;
  697.      otherwise the insn should be executed only if the branch is not
  698.      taken.  *Note Delay Slots::.
  699.    These expression codes appear in place of a side effect, as the body
  700. of an insn, though strictly speaking they do not always describe side
  701. effects as such:
  702. `(asm_input S)'
  703.      Represents literal assembler code as described by the string S.
  704. `(unspec [OPERANDS ...] INDEX)'
  705. `(unspec_volatile [OPERANDS ...] INDEX)'
  706.      Represents a machine-specific operation on OPERANDS.  INDEX
  707.      selects between multiple machine-specific operations.
  708.      `unspec_volatile' is used for volatile operations and operations
  709.      that may trap; `unspec' is used for other operations.
  710.      These codes may appear inside a `pattern' of an insn, inside a
  711.      `parallel', or inside an expression.
  712. `(addr_vec:M [LR0 LR1 ...])'
  713.      Represents a table of jump addresses.  The vector elements LR0,
  714.      etc., are `label_ref' expressions.  The mode M specifies how much
  715.      space is given to each address; normally M would be `Pmode'.
  716. `(addr_diff_vec:M BASE [LR0 LR1 ...])'
  717.      Represents a table of jump addresses expressed as offsets from
  718.      BASE.  The vector elements LR0, etc., are `label_ref' expressions
  719.      and so is BASE.  The mode M specifies how much space is given to
  720.      each address-difference.
  721. File: gcc.info,  Node: Incdec,  Next: Assembler,  Prev: Side Effects,  Up: RTL
  722. Embedded Side-Effects on Addresses
  723. ==================================
  724.    Four special side-effect expression codes appear as memory addresses.
  725. `(pre_dec:M X)'
  726.      Represents the side effect of decrementing X by a standard amount
  727.      and represents also the value that X has after being decremented.
  728.      x must be a `reg' or `mem', but most machines allow only a `reg'.
  729.      m must be the machine mode for pointers on the machine in use.
  730.      The amount X is decremented by is the length in bytes of the
  731.      machine mode of the containing memory reference of which this
  732.      expression serves as the address.  Here is an example of its use:
  733.           (mem:DF (pre_dec:SI (reg:SI 39)))
  734.      This says to decrement pseudo register 39 by the length of a
  735.      `DFmode' value and use the result to address a `DFmode' value.
  736. `(pre_inc:M X)'
  737.      Similar, but specifies incrementing X instead of decrementing it.
  738. `(post_dec:M X)'
  739.      Represents the same side effect as `pre_dec' but a different
  740.      value.  The value represented here is the value X has before being
  741.      decremented.
  742. `(post_inc:M X)'
  743.      Similar, but specifies incrementing X instead of decrementing it.
  744.    These embedded side effect expressions must be used with care.
  745. Instruction patterns may not use them.  Until the `flow' pass of the
  746. compiler, they may occur only to represent pushes onto the stack.  The
  747. `flow' pass finds cases where registers are incremented or decremented
  748. in one instruction and used as an address shortly before or after;
  749. these cases are then transformed to use pre- or post-increment or
  750. -decrement.
  751.    If a register used as the operand of these expressions is used in
  752. another address in an insn, the original value of the register is used.
  753. Uses of the register outside of an address are not permitted within the
  754. same insn as a use in an embedded side effect expression because such
  755. insns behave differently on different machines and hence must be treated
  756. as ambiguous and disallowed.
  757.    An instruction that can be represented with an embedded side effect
  758. could also be represented using `parallel' containing an additional
  759. `set' to describe how the address register is altered.  This is not
  760. done because machines that allow these operations at all typically
  761. allow them wherever a memory address is called for.  Describing them as
  762. additional parallel stores would require doubling the number of entries
  763. in the machine description.
  764. File: gcc.info,  Node: Assembler,  Next: Insns,  Prev: Incdec,  Up: RTL
  765. Assembler Instructions as Expressions
  766. =====================================
  767.    The RTX code `asm_operands' represents a value produced by a
  768. user-specified assembler instruction.  It is used to represent an `asm'
  769. statement with arguments.  An `asm' statement with a single output
  770. operand, like this:
  771.      asm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z));
  772. is represented using a single `asm_operands' RTX which represents the
  773. value that is stored in `outputvar':
  774.      (set RTX-FOR-OUTPUTVAR
  775.           (asm_operands "foo %1,%2,%0" "a" 0
  776.                         [RTX-FOR-ADDITION-RESULT RTX-FOR-*Z]
  777.                         [(asm_input:M1 "g")
  778.                          (asm_input:M2 "di")]))
  779. Here the operands of the `asm_operands' RTX are the assembler template
  780. string, the output-operand's constraint, the index-number of the output
  781. operand among the output operands specified, a vector of input operand
  782. RTX's, and a vector of input-operand modes and constraints.  The mode
  783. M1 is the mode of the sum `x+y'; M2 is that of `*z'.
  784.    When an `asm' statement has multiple output values, its insn has
  785. several such `set' RTX's inside of a `parallel'.  Each `set' contains a
  786. `asm_operands'; all of these share the same assembler template and
  787. vectors, but each contains the constraint for the respective output
  788. operand.  They are also distinguished by the output-operand index
  789. number, which is 0, 1, ... for successive output operands.
  790.